load("js/luaclient.js")
load("js/v6/citic/citic_debit_login.js")
load("js/v6/citic/citic_debit_crawlhandle.js")

var v6_citic_debit_java_funcs = {

    openHomePage: function () {
        var html = get("https://i.bank.ecitic.com/perbank6/signIn.do");
        storeDataToFile(context, html, "login_1.txt");
    },
    checkControlAvailable: function () {
        return true;
    },
    checkTargetWebsiteAvailable: function () {
        return true;

    },
    //检查代理是否可用
    checkProxyAvailable: function () {
        var checkPrxoy = function () {
            return is_exist_by_id("certListCite");
        }
        var getErrorMsg = function () {
            return "代理ip异常";
        }
        return assertTrueOrThrowException("", checkPrxoy, getErrorMsg)
    },
    login: function () {
        inputBaseCitic();
        inputImgCitic();
        inputSmsCitic();
    },
    needRefreshHomePageOrNot: function () {
        return equals(context.get("currentErrorCode"), BALO_99602_50)
    },
    needResetEnvironment: function () {
        return false;
    },
    //抓取过程
    crawl: function () {
        //中信借记卡抓取解析主流程
        debit_crawl_main();

        var list = new ArrayList();

        //从上下文，获取数据对象集合
        var data_list = context.get(ALL_DATA);
        logger.info("借记卡data_list=="+data_list.size())
        for(var i=0;i<data_list.size( );i++){
            //添加每个卡对象
            list.add(data_list.get(i));
        }
        //添加上下文
        context.put("debit_data",list);
    },
    exitLogin: function () {
    }
};
